/**
 * 组合函数，串行执行
 */
const compose = (fns) =>{
	if(!Array.isArray(fns)){
		fns = [fns]
	}
	return function(arg){
		return fns.reduce((prev,next)=>prev.then(()=>next()),Promise.resolve())
	}
}
const fn1=()=>{
	return new Promise(resolve=>{
		setTimeout(()=>{
			console.log('01');
			resolve()
		},3000)
	})
}
const fn2=()=>{
	return new Promise(resolve=>{
		setTimeout(()=>{
			console.log('02');
			resolve()
		},2000)
	})
}
const fn3=()=>{
	return new Promise(resolve=>{
		setTimeout(()=>{
			console.log('03');
			resolve()
		},1000)
	})
}
compose([fn1,fn2,fn3])()